Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Code-editor agent and Debug agent prototypes#286

Closed
rblalock wants to merge 21 commits intomainfrom
code-editor-prototype
Closed

Code-editor agent and Debug agent prototypes#286
rblalock wants to merge 21 commits intomainfrom
code-editor-prototype

Conversation

@rblalock
Copy link
Copy Markdown
Member

@rblalock rblalock commented May 11, 2025

✨ Experimental Debug-Agent and Code-Edit Agent

These are prototypes to demonstrate some concepts / ideas coming down the pike. I fully expect all of this to be nuked soon :-)

For now, both of these agents use the Go Anthropic SDK. You must have a ANTHROPIC_API_KEY on your path for these to work. In the future this won't be necessary but for the prototype this is an easy way to test.


Code editing agent

This runs when a new agent is created via the CLI. It will ask the user the purpose of the agent, which is used as a prompt to change the agent template accordingly. You must add the experimental flag to use it:

agentuity agent create --experimental-code-agent

Debug agent

This agent runs when running agentuity dev. It will watch logs and if there is an error or crash, etc. it will try to figure out what the problem is and debug it for you. You must add the experimental flag to use it:

agentuity dev --experimental-debug-agent


Some opinions on the state of this:

  • There's a balance to what parts of an agent (or multi-agents) live locally like this, and what should be in the cloud. Need to discuss.
  • Ideally this isn't bound to just Anthropic. For example - for error logs, we could do a pass using Groq and LLama4 for speed and cheapness, before going deeper with a beefier model (if/when needed). This means we need to abstract how some of this works.
  • We need to be careful how these get invoked. Just need to be smarter than this code currently is. For example - right now if there's a continuous set of errors, the debug agent will just keep chugging through them, if they're new / different.

other thoughts:

there might be multiple errors that come in at once. which should the agent focus on? maybe we should chunk them together and let it analyze a bunch in a time window?

that means we might need a more dynamic tui input, depending on if the agent wants to ask a question (like "which error should i analyze" and give a list)

realistically there could be tons of stdout between some of this agent stdout...how do we best handle? should the agent ask the user in the terminal if it should analyze, and it just doesn't show anything else until the user performs an action?

might be an argument for a TUI with tabs, one of the typical dev stuff and the other for the agent

@rblalock rblalock marked this pull request as ready for review May 14, 2025 15:15
Copy link
Copy Markdown
Contributor

@robindiddams robindiddams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some styling stuff. and i showed you how to fix the embed

I think the reflector stuff on the anthropic tools api is okay for this pr, but we can probably use a generator to make all the correct types at compile-time and get some more safefy/speed

Also since tools/debugagent/codeagent are all kinda one unit maybe it's better to just stick them all in a subdir internal/agents/ they can still be separate modules. since tools especially is a generic sounding module and it would likely not be used outside of an agent.

Comment thread cmd/dev.go
Comment on lines +25 to +29

"github.com/agentuity/cli/internal/debugagent"
debugmon "github.com/agentuity/cli/internal/dev/debugmon"

"github.com/agentuity/cli/internal/dev/linkify"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/agentuity/cli/internal/debugagent"
debugmon "github.com/agentuity/cli/internal/dev/debugmon"
"github.com/agentuity/cli/internal/dev/linkify"
"github.com/agentuity/cli/internal/debugagent"
"github.com/agentuity/cli/internal/dev/debugmon"
"github.com/agentuity/cli/internal/dev/linkify"

Comment on lines +20 to +34
)

// NOTE: I think we should be able to use that fancy go:embed thing here
// but the import gets nuked when we build the CLI, so doing this nasty
// init() thing instead.
var systemPrompt string

func init() {
_, file, _, _ := runtime.Caller(0)
base := filepath.Dir(file)
p := filepath.Join(base, "./debug-system-prompt.txt")
if data, err := os.ReadFile(p); err == nil {
systemPrompt = string(data)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to use a blind import:

Suggested change
)
// NOTE: I think we should be able to use that fancy go:embed thing here
// but the import gets nuked when we build the CLI, so doing this nasty
// init() thing instead.
var systemPrompt string
func init() {
_, file, _, _ := runtime.Caller(0)
base := filepath.Dir(file)
p := filepath.Join(base, "./debug-system-prompt.txt")
if data, err := os.ReadFile(p); err == nil {
systemPrompt = string(data)
}
}
_ "embed"
)
//go:embed debug-system-prompt.txt
var systemPrompt string

if your editor removes that still thats an issue with your config.

Comment on lines +14 to +30
)

// NOTE: I think we should be able to use that fancy go:embed thing here
// but the import gets nuked when we build the CLI, so doing this nasty
// init() thing instead.
var systemPrompt string

func init() {
_, file, _, _ := runtime.Caller(0)
base := filepath.Dir(file)
p := filepath.Join(base, "./code-system-prompt.txt")
if data, err := os.ReadFile(p); err == nil {
systemPrompt = string(data)
} else {
systemPrompt = ""
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here too.

Comment on lines +41 to +44
return errors.New("codeagent: Dir must be provided")
}
if opts.Goal == "" {
return errors.New("codeagent: Goal must be provided")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistent casing, errors should start lowercase

Suggested change
return errors.New("codeagent: Dir must be provided")
}
if opts.Goal == "" {
return errors.New("codeagent: Goal must be provided")
return errors.New("codeagent: dir must be provided")
}
if opts.Goal == "" {
return errors.New("codeagent: goal must be provided")

Comment thread cmd/project.go
Comment on lines +344 to +345
goalFlag, _ := cmd.Flags().GetString("goal")
agentGoal = goalFlag
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what foalFlag is supposed to do

Suggested change
goalFlag, _ := cmd.Flags().GetString("goal")
agentGoal = goalFlag
agentGoal, _ := cmd.Flags().GetString("goal")

Comment on lines +58 to +62
trace := func(format string, args ...interface{}) {
if opts.Logger != nil {
opts.Logger.Trace(format, args...)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a little weird, we never optionally allow a logger, expect it and the caller can either tune the desired level or pass a logger.NewNoOpLgger

Suggested change
trace := func(format string, args ...interface{}) {
if opts.Logger != nil {
opts.Logger.Trace(format, args...)
}
}
logger := opts.Logger.With(map[string]any{"pkg":"debugagent"})

if useCache {
keyHash := hash(opts.Error)
cachePath := filepath.Join(cacheDir, keyHash+".txt")
_ = writeCache(cachePath, cacheEntry{Analysis: analysis})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the error or omit _ =

if useCache {
keyHash := hash(opts.Error)
cachePath := filepath.Join(cacheDir, keyHash+".txt")
_ = writeCache(cachePath, cacheEntry{Analysis: analysis})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

@jhaynie
Copy link
Copy Markdown
Member

jhaynie commented May 15, 2025

i think we need to hold off on merging this until after the devmode changes and also need to reconsider some of this based on conversation internally about how to reconcile the code agent and other dev agents.

@rblalock
Copy link
Copy Markdown
Member Author

Yup makes sense. I'll close this - but at least we have some reference points for some ideas

@rblalock rblalock closed this May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants